
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    select: '',
    species: [], 
    aaa: false,
    scrollTop:0,
    language:[],
  },
  // 分类切换
  sort_click: function (e) {
    var that = this;
    if (!that.data.aaa && e.currentTarget.dataset.index == 7) {
      that.setData({
        aaa: true,
        scrollTop:0,
      })
    }else{
      that.setData({
        language: that.data.species[e.currentTarget.dataset.index].content,
        select: e.currentTarget.dataset.index,
        scrollTop: 0,
      })
    }

  },
  // 语术选择
  put_text: function (e) {
    wx.setStorage({ key: "blessing_text", data: e.currentTarget.dataset.text })//缓存祝福语
    wx.setStorage({ key: "currentTab", data: 1 })//缓存祝福语
    wx.reLaunch({ url: '/pages/voice_box/index/index',})
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.showLoading({ title: '加载中', mask: true })
    var that = this;
    app.token_md5();     
    wx.request({
      url: app.url2 + 'api/kou',
      data: {
        openid: wx.getStorageSync('openid'),
        token: wx.getStorageSync('token_md5'),
      },
      header: {},
      success: function(res) {
          console.log(res.data);
          that.setData({
            species: res.data,
            language: res.data[1].content,
            select: 1,
          })
          wx.hideLoading();        
      }
    })

  }

  
})